package com.srlg.webflux.controller;

import com.srlg.webflux.entity.Author;
import com.srlg.webflux.service.AuthorService;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * @desc: 作者控制器
 * @author: srlg li
 * @date: 2024/1/7 15:04
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("author")
public class AuthorController {

    private final AuthorService authorService;

    @GetMapping("getAll")
    public Flux<Author> getAllAuthor() {
        return authorService.getAllAuthor();
    }

    public String getMethodName(@RequestParam String param) {
        return new String();
    }
    
    /**
     * 用id获取作者
     * @param id 主键
     * @return Author
     */
    @GetMapping("getAuthor/{id}")
    public Mono<Author> getAuthorById(@PathVariable Long id) {
        return authorService.findAuthorById(id);
    }
}
